package com.hdu.other.dp.maxSubArraySum;



public class lc53 {
    class Solution {
        public int maxSubArray(int[] nums) {
            int sum = Integer.MIN_VALUE;
            int presum = Integer.MIN_VALUE;
            for (int i = 0; i < nums.length; i++) {
                if (presum < 0)
                {
                    presum = nums[i];
                }
                else
                {
                    presum += nums[i];
                }
                if (presum > sum) sum = presum;
            }
            return sum;
        }
    }
}
